package cn.com.bluemoon.daps.model.controller.api;

import cn.com.bluemoon.daps.api.model.RemoteModelGroupService;
import cn.com.bluemoon.daps.common.constant.ServiceNameConstants;
import cn.com.bluemoon.daps.common.datascope.BmPermission;
import cn.com.bluemoon.daps.common.domain.ResultBean;
import cn.com.bluemoon.daps.model.entity.DapDataModelGroup;
import cn.com.bluemoon.daps.model.service.DapDataModelGroupService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Jarod.Kong
 * @date 2020/12/23 17:26
 */
@Api(tags = {"FeignClient服务-模型分组内部服务"})
@RequestMapping(ServiceNameConstants.DapsApiModel.API_MODEL_TABLE_GROUP)
@BmPermission(value = "", name = "服务注册-模型分组", ignore = true)
@RestController
@Slf4j
public class DapDataModelGroupServiceApi implements RemoteModelGroupService {
    @Resource
    private DapDataModelGroupService groupService;

    @GetMapping("/groups")
    @ApiOperation("获取模型分组列表")
    public ResultBean<List<DapDataModelGroup>> modelGroups(@RequestParam("modelId") String modelId) {
        LambdaQueryWrapper<DapDataModelGroup> eq = groupService.bmLambdaQuery().eq(DapDataModelGroup::getModelId, modelId);
        List<DapDataModelGroup> dapDataModelGroups = groupService.list(eq);
        return ResultBean.ok(dapDataModelGroups);
    }
}
